// Tab页的data
// 用户
const user_tabList=[
  {
    text: "首页",
    iconPath: "/images/home_2.png",
    selectedIconPath: "/images/home.png",
    pagePath: "/pages/index/index"
  },
  {
    text: "报修",
    iconPath: "/images/repair_2.png",
    selectedIconPath: "/images/repair.png",
    pagePath: "/pages/repair/repair"
  },
  {
    text: "我的",
    iconPath: "/images/mine_2.png",
    selectedIconPath: "/images/mine.png",
    pagePath: "/pages/mine/mine"
  }
]
// 管理员
const admin_tabList=[
  {
    text: "首页",
    iconPath: "/images/home_2.png",
    selectedIconPath: "/images/home.png",
    pagePath: "/pages/index/index"
  },
  {
    text: "我的",
    iconPath: "/images/mine_2.png",
    selectedIconPath: "/images/mine.png",
    pagePath: "/pages/mine/mine"
  }
]
// 维修工
const worker_tabList=[
  {
    text: "首页",
    iconPath: "/images/home_2.png",
    selectedIconPath: "/images/home.png",
    pagePath: "/pages/index/index"
  },
  {
    text: "我的",
    iconPath: "/images/mine_2.png",
    selectedIconPath: "/images/mine.png",
    pagePath: "/pages/mine/mine"
  }
]

// 更新角色
const updateRoleTab = (that,role) => {
  if (role == "user") {
    if (typeof that.getTabBar === 'function' && that.getTabBar()) {
      that.getTabBar().setData({tabList:user_tabList});
    }
  }else if (role == "admin") {
    if (typeof that.getTabBar === 'function' && that.getTabBar()) {
      that.getTabBar().setData({tabList:admin_tabList});
    }
  }else if (role == "worker") {
    if (typeof that.getTabBar === 'function' && that.getTabBar()) {
      that.getTabBar().setData({tabList:worker_tabList});
    }
  }
}

// 更新底部高亮
const updateTabIndex = (that, index) => {
  if (typeof that.getTabBar === 'function' && that.getTabBar()) {
    that.getTabBar().setData({currentIndex:index});
  }
}

// 将可调用的方法抛出让外面调用
module.exports = {
  updateRoleTab, updateTabIndex
}